import request from '@/utils/request'

// 根据用户ID获取用户信息
export function getUserInfo(userId) {
  return request({
    url: `/user/info/${userId}`,
    method: 'get'
  })
}

// 根据用户ID获取用户信息
export function userDetail(userId) {
  return request({
    url: `/user/user_detail`,
    method: 'get',
    params: {
      userId
    }
  })
}

export function login(data) {
  return request({
    url: '/auth/api/auth/login',
    method: 'post',
    data
  })
}

// 批量保存
export function batchCreate(data) {
  return request({
    url: '/user/batchCreate',
    method: 'post',
    data
  })
}

// 导出
export function exportUser(data) {
  return request({
    url: '/user/exportUser',
    method: 'post',
    data,
    responseType: 'blob'
  })
}

// 获取用户列表数据
export function userList(data = {}) {
  return request({
    url: '/user/list',
    method: 'post',
    data
  })
}

// 创建用户
export function createUser(data) {
  return request({
    url: '/user/create',
    method: 'post',
    data
  })
}

// 编辑用户
export function editUser(data) {
  return request({
    url: '/user/update',
    method: 'post',
    data
  })
}

// 删除用户
export function deleteUser(data) {
  return request({
    url: '/user/delete',
    method: 'post',
    data
  })
}

// 删除用户
export function batchImportUser(data) {
  return request({
    url: '/user/importUser',
    method: 'post',
    data
  })
}

// 发送短信验证码
export function phoneCode(phone, type) {
  return request({
    //url: `/server/api/sms/getPhoneCode/${type}/${phone}`,
    url: `/server/api/sms/getPhoneCode`,
    method: 'GET',
    params: {
      phone, type
    }
  })
}

// 手机号码验证
export function validPhone(data) {
  return request({
    url: '/user/validPhone',
    method: 'post',
    data
  })
}

// 编辑用户基本信息
export function editUserBaseInfo(data) {
  return request({
    url: '/user/editUserBaseInfo',
    method: 'post',
    data
  })
}

// 发送邮件验证码
export function sendEmail(email) {
  return request({
    url: `/server/email/sendEmail`,
    method: 'get',
    params: {
      email
    }
  })
}

// 邮箱验证
export function validEmail(data) {
  return request({
    url: '/user/validEmail',
    method: 'post',
    data
  })
}

// 更新密码
export function updateUserPwd(data) {
  return request({
    url: '/user/updateUserPwd',
    method: 'post',
    data
  })
}

// 检查用户是否有新消息
export function newMessageCount() {
  return request({
    url: '/user/message/newMessageCount',
    method: 'get',
  })
}

// 删除消息
export function deleteMessage(data) {
  return request({
    url: '/user/message/deleteMessage',
    method: 'post',
    data
  })
}

// 获取消息列表
export function getMessageList(data) {
  return request({
    url: '/user/message/messageList',
    method: 'post',
    data
  })
}

// 全部已读消息
export function allReadMessage() {
  return request({
    url: '/user/message/allReadMessage',
    method: 'get'
  })
}

// 删除全部消息
export function deleteAllMessage() {
  return request({
    url: '/user/message/deleteAllMessage',
    method: 'get'
  })
}

// 修改用户头像
export function updateUserAvatar(avatarUrl) {
  return request({
    url: '/user/updateUserAvatar',
    method: 'get',
    params: {
      avatarUrl
    }
  })
}












export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
}
